var t = {};

module.exports = function(i) {
    var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
    return new Promise(function(f, n) {
        try {
            if (e.success = function(t) {
                f(t);
            }, e.fail = function(t) {
                n(t);
            }, t[i]) {
                if ("function" == typeof e.success) {
                    var h = JSON.parse(JSON.stringify(t[i]));
                    if ("number" == typeof e.width) {
                        var s = getApp().globalData.windowWidth / 750;
                        h.width = e.width * s, h.height = e.width / t[i].width * t[i].height * s;
                    }
                    e.success(h);
                }
            } else wx.getImageInfo({
                src: i,
                success: function(f) {
                    if ("getImageInfo:ok" === f.errMsg) {
                        if ("function" == typeof e.success) {
                            var n = {
                                path: f.path,
                                width: f.width,
                                height: f.height
                            };
                            if (t[i] = JSON.parse(JSON.stringify(n)), "number" == typeof e.width) {
                                var h = getApp().globalData.windowWidth / 750;
                                n.width = e.width * h, n.height = e.width / t[i].width * t[i].height * h;
                            }
                            e.success(n);
                        }
                    } else "function" == typeof e.fail && e.fail(f);
                },
                fail: function(t) {
                    "function" == typeof e.fail && e.fail(t);
                }
            });
        } catch (t) {
            f(t);
        }
    });
};